<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>offsetHeight</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    body {
      background-color: #f1f1f1;
    }

    #container {
      width: 300px;
      height: 200px;
      padding: 20px;
      margin: 30px;
      border: 5px solid #ccc;
      box-sizing: border-box;
      overflow: auto;
      background-color: #fff;
    }

    #content {
      width: 600px;
      height: 500px;
      background-color: #f1f1f1;
      display: inline-block;
    }
  </style>
</head>

<body>

  <div id="container">
    <div id="content">
      <p>offsetHeight scrollHeight clientHeight 区别</p>
    </div>
  </div>

  <script>
    const container = document.getElementById('container')
    console.log('offsetHeight', container.offsetHeight)
    console.log('offsetWidth', container.offsetWidth)
    console.log('clientWidth', container.clientWidth)
    console.log('clientHeight', container.clientHeight)
    console.log('scrollWidth', container.scrollWidth)
    console.log('scrollHeight', container.scrollHeight)

    // scrollTop scrollLeft 需滚动之后获取
  </script>
</body>

</html>